from unittest import TestCase
import requests


# Create your tests here.


class DealerTest(TestCase):
    base_url = 'http://127.0.0.1:8000'

    def test_addDealer(self):
        url = self.base_url + '/dealer/addDealer/'
        json_data = {
            'company': '陕西喊山酒业1',
            "address": '辛家庙',
            'name': '伏虎',
            'phone': '456',
            'area': '雁塔',
            'level': 'A',
            'staff_id': '45f0a1f90df148e3a2693a5494db95a9',
            'status': '正常'
        }
        resp = requests.post(url, data=json_data)
        print(resp.text)

    def test_findDealer(self):
        url = self.base_url + "/dealer/findDealer/?dealer_id=cd712e7a613d47ff9e34e2472d7d0330"
        resp = requests.get(url)
        print(resp.text)

    def test_alterDealer(self):
        url = self.base_url + '/dealer/alterDealer/'
        json_data = {
            'dealer_id': '85ed432b8add47a0995395aa0159d3f4',
            'company': '天上人间2',
            "address": '立人科技园A座',
            'name': '贾山',
            'phone': '123123',
            'area': '未央区',
            'level': 'c',
            'staff_id': '45f0a1f90df148e3a2693a5494db95a9',
            'status': '注销'
        }
        resp = requests.put(url, data=json_data)
        print(resp.text)

    def test_delDealer(self):
        url = self.base_url + '/dealer/delDealer/?dealer=6a7a49a68a124a5a852ecb7a8d3c25b0'
        resp = requests.get(url)
        print(resp.text)


    def test_findDealerAll(self):
        # 业务经理
        # url = self.base_url + '/dealer/findDealerAll/?staff_id=6a7a49a68a124a5a852ecb7a8d3c25b0'
        # 总经理
        url = self.base_url + '/dealer/findDealerAll/?staff_id=45f0a1f90df148e3a2693a5494db95a9'
        resp = requests.get(url)
        print(resp.text)